Contents

Properties	Events

DBPush v2.0 June 1995

Description	The DBPush command button control emulates the 3D command button control (SSCommand) supplied with Visual Basic Professional Edition 3.0. In addition it supports several enhancements to SSCommand.

File Name	DBPUSH.VBX

Object Type	DBPush

Remarks	This documentation describes only the properties where DBPush differs from the standard Windows command button.

About DBPush

Distribution Notes

Revision History

Special Features and Considerations


    Revision History

v2.0:	Long forgotten property added: HelpContextID.

New property added: DropShadow.

v1.9:	Added four more styles for AutoPictureDisabled.

Added two more predefined pictures.

v1.8:	On-line help was added, thanks to David A. Karp.

New property added: AutoPictureDisabled.

v1.7:	Some minor glitches were fixed.

An about box was finally added.

v1.6:	BUGFIX: 256-color pictures were handled incorrectly in v1.5.

New property added: PictureFromEdge.

New property added: PredefPicture.

Added new Style: elliptical buttons.

v1.5:	BUGFIX: Two pictures (if used) were not released from memory.

New property added: FocusRect.

New property added: OutlineSize.

The property Outline is superseded and doesn't show up in design mode.

New property added: Transparent.

New property added: TransColor.

The button is now first drawn in an off-screen buffer to prevent flicker.

Double pipe characters may now be used instead of CRLF in caption.

v1.4:	New property added: Style.

New property added: CustomCursor.

v1.3:	New property added: PictureDisabled.

New property added: ForeColorDisabled.

New property added: Font3DDisabled.

Added exported function for easy version control.

v1.2:	A minor error in the default setting of VertAlignment was fixed.

Placement may now be "Text on top of picture" as well.

v1.1:	New property added: ForceUp.

New property added: WasDblClick.

New property added: VertAlignment.

Nov 94:	BUGFIX: Right mouse button no longer generates a Click event.

Library name changed from PUSH to DBPUSH.

Version info is now included in the VBX.

New property added: ForceDown.

New property added: CornerColor.

Oct 94:	Beta release.


    Distribution Notes

You have the right to do whatever you want with DBPush, as long as you don't attempt to modify any of its code. "Do whatever you want" includes using DBPush in your own commercial applications and distributing it for free.

When the control is loaded in design mode a message is sometimes displayed. This message may not be removed or changed in any way. Anyway, the message won't ever appear at run-time.

I'm giving DBPush away for free. If you should decide to use it in an application of yours, this means that I have saved you a whole lot of trouble, time and $$$ doing it yourself. Therefore I think a nice gesture would be to include some sort of credit in your application's about box and/or documentation. You could include the name of the VBX, my name and my e-mail address. I would be glad if you did this. Anyway - happy VB programming with DBPush!


    About DBPush

This control was developed by Dan Byström. For more information, contact me at e-mail: "dan.bystrom@adb-partner.se" or phone: +46 708 68 65 78 (no support calls, please). I would be happy to discuss development of customized VBX'es or OCX'es for you.

This help file was compiled by David A. Karp - email: daaron@ocf.berkeley.edu.

Have you tried any other of my freeware VBXes?

•	DBTTip allows you to add tool tips to your application without writing a single line of code! The tool tip bubble need not be rectangular - use any WMF-picture!

•	DBAppMon is an interface to TOOLHELP.DLL and VER.DLL. Among other things, it will generate events when any other application starts or stops.

•	DBHots allows you to interactively create irregular shaped hot spots with custom cursors.


   Properties

Alignment	FontName	PictureDisabled

AutoPictureDisabled	FontSize	PictureDown

BackColor	FontStrikethru	PictureFromEdge

BackColorDown	FontUnderline	Placement

BevelWidth	ForceDown	PredefPicture

Caption	ForceUp	Style

CornerColor	ForeColorDisabled	TabIndex

CustomCursor	Height	TabStop

DragIcon	HelpContextID	Tag

DragMode	hWnd	Top

DropShadow	Index	TransColor

Enabled	Left	Transparent

FocusRect	MousePointer	VertAlignment

Font3D	Name	Visible

Font3DDisabled	OutlineSize	WasDblClick

FontBold	Parent	Width

FontItalic	Picture


   Events

Click	KeyUp

DragDrop	LostFocus

DragOver	MouseDown

GotFocus	MouseUp

KeyDown	MouseMove

KeyPress


    Special Features and Considerations

Group push buttons

It is possible to use DBPush as a group push button. If you want only one button in a group to be down at the same time, just make a control array out of the buttons of a group and include the following code in the click event:

Sub DBPush1_Click (Index As Integer)

  DBPush1(nCurrentButtonDown).ForceDown = False

  DBPush1(Index).ForceDown = True

  nCurrentButtonDown = Index

End Sub

Also declare this somewhere (in the form or a module):

Dim nCurrentButtonDown As Integer

You may also want to set the BackColorDown property to &H00E0E0E0& in buttons used as group push buttons.

Palette considerations

DBPush is not made palette aware. This is done on purpose; the user would probably not like to see palette shifts each time the focus is moved to a new button. This doesn't mean that you can't use 256 color pictures, however. The only thing you need to do is to have the same palette as the button uses realized in some other way. The easiest way to do this is to put a 1x1 picture with the same palette in an image control on the form and move it outside the visible area.

Cancel and Default buttons

The standard VB command button have the Cancel and Default properties which can't(?) be mimicked by a custom control. A primitive work-around is to place normal command buttons outside the visible area of the form, set their Cancel and Default properties respectively and let their click events call the corresponding DBPush buttons. Another way is to check for Enter and Esc in the Form's KeyPress event.

Version control

The following code shows an easy way to check the version of DBPUSH.VBX before its properties are accessed by VB. In a global module, put the following declaration:

Declare Function DBPushVersion Lib "dbpush.vbx" () As Integer

Then use a  Sub Main() as your program's entry point:

Sub Main()

  If Hex$(DBPushVersion()) < "0190" Then

    MsgBox "Your DBPUSH.VBX is too old for this application!", 16

    End

  End If

'Load your main form here

End Sub


ForceDown
    ForceDown Property

Description	Forces the button to be drawn in a depressed state.

Remarks	This property may be used to mimic the behavior of a check button. Just toggle the property value (DBPush1.ForceDown = Not DBPush1.ForceDown) in the Click event.

Data Type	Integer (Boolean)


Font3DDisabled
    Font3DDisabled Property

Description	Determines the 3D style of the caption when the button is in a disabled state.

Remarks	Try to set ForeColorDisabled to dark gray and Font3DDisabled to "3 - Inset with light shading".

Data Type	Integer (enumerated)


PictureDown
    PictureDown Property

Description	Determines the picture to be displayed when the button is depressed.

Remarks	If no picture is assigned to this property, the Picture property is used for the depressed button as well.

Data Type	Picture


FocusRect
    FocusRect Property

Description	Determines whether a focus rectangle shall be drawn when the button gets focus.

Remarks	This property is True by default.

Data Type	Integer (Boolean)


CustomCursor
    CustomCursor Property

Description	Sets a custom cursor shape to use when the mouse is moved over the button. CustomCursor takes precedence over the MousePointer property.

Remarks	Just like the DragIcon property, the cursors must be saved as icons in an .ICO file. This is because VB handles .ICO files by default, but not .CUR files. This property is somewhat more restrictive than DragIcon; only the white color in the icon translates to white color in the cursor - all other colors translate to black.

Data Type	Picture (Icon only)


CornerColor
    CornerColor Property

Description	Determines the color of the corners on the outline. Instead of implementing a RoundedCorners property like SSCommand (which always uses light gray to draw smooth corners), DBPush lets you decide what color to use.

Remarks	This property is set to black by default which means that the control appears to have sharp edges. To mimic a RoundedCorners property, set CornerColor to the same value as the parent form's background color.

Data Type	Long


Caption
    Caption Property

Description	The button's caption text.

Remarks	Unlike SSCommand, DBPush is able to display several lines of caption text. If the caption text doesn't fit on one line (or if it contains CRLF breaks) it is automatically wrapped onto several lines. Beginning with DBPush v1.5, a pair of pipe characters (or "vertical bars") may be used instead of CRLF. This makes it possible to create hard line breaks in design mode.

Data Type	String


WasDblClick
    WasDblClick Property

Description	In the Click event, this property may be used to determine if the Click originated from a DblClick.

Remarks	Command buttons should normally not respond to DblClicks, but this is nevertheless a method to do it.

Data Type	Integer (Boolean)


BackColorDown
    BackColorDown Property

Description	Determines the background color of the button when the button is depressed.

Remarks	This property is set to light gray by default and it probably looks best that way, unless you want to use the button as a two-state button.

Data Type	Long


BackColor
    BackColor Property

Description	Determines the background color of the button.

Remarks	This property is set to light gray by default and it probably looks best that way.

Data Type	Long


Alignment
    Alignment Property

Description	Determines the alignment of the caption text within the push button.

Remarks	The Alignment property settings are:

Setting	Description

0	The caption text appears left-justified.

1	The caption text appears right-justified.

2	(Default) The caption text appears (horizontally) centered.

Data Type	Integer (enumerated)


PictureFromEdge
    PictureFromEdge Property

Description	Determines the distance between the buttons edge and the picture given in pixels.

Remarks	The distance may be a negative number.

Data Type	Integer


PictureDisabled
   PictureDisabled Property

Description	Determines the picture to be displayed when the button is disabled.

Remarks	If no picture is assigned to this property, the Picture property is used for the disabled button as well.

Data Type	Picture


OutlineSize
   OutlineSize Property

Description	Determines the size of the black outline (or border) around the button. Set this property to zero to remove the outline.

Remarks	This property may be used to indicate a default button (by setting OutlineSize to two).

Data Type	Integer


ForeColorDisabled
    ForeColorDisabled Property

Description	Determines the caption color when the button is in a disabled state.

Remarks	Try to set ForeColor to dark gray and Font3DDisabled to "3 - Inset with light shading".

Data Type	Long


ForceUp
    ForceUp Property

Description	Forces the button to always be drawn in up state.

Remarks	By enabling this property the button no longer behaves like a command button, but more like a specialized picture control. When this property is set, no focus rectangle is drawn around the picture or the caption.

This property does not affect the events the button receives in any way.

Data Type	Integer (Boolean)


VertAlignment
   VertAlignment Property

Description	Aligns the caption text vertically within the area not occupied by a picture.

Remarks	The VertAlignment property settings are:

Setting	Description

0	Caption is aligned at the top.

1	Caption is aligned at the bottom.

2	Caption is centered vertically.

Every time the Picture property or the Placement property is altered, this property changes to the (static) alignment used before version 1.1. This is done purely to ensure version compatibility. Beware!

Data Type	Integer (enumerated)


Transparent
    Transparent Property

Description	This property is used to enable the TransColor property.

Remarks	See the TransColor property.

Data Type	Integer (Boolean)


TransColor
    TransColor Property

Description	This property is used to make one color of a picture transparent, which means that this particular color is replaced with the buttons background color.

Remarks	For this property to have any effect, the Transparent property must be enabled. Instead of using this feature you may consider repainting the picture, since both extra execution time and system resources are needed each time the button is repainted. This property is however useful when the button uses a different background color when in a depressed state (using the BackColorDown property).

Data Type	Long


    BevelWidth

Description	Sets or returns the width of the bevel along the four sides of the command button to determine the height of the three-dimensional shadow effect.

Remarks	The setting for this property determines the number of pixels used to draw the bevel that surrounds the command button.

Data Type	Integer


Style
    Style Property

Description	Gives the button a different style than normal command buttons.

Remarks	The Style property settings are:

Setting	Description

0	(Default) Normal.

1	Sink deep. When the button is depressed it appears to sink below the surface of the form. This works best if OutlineSize is zero.

2	Elliptical button. (The CornerColor property must be set to the form's background color.)

3	Elliptical button with "sink deep" style.

Data Type	Integer (enumerated)


PredefPicture
    PredefPicture Property

Description	Selects one of three predefined pictures.

Remarks	The PredefPicture property settings are:

Setting	Description

0	(Default) No predefined picture.

1	OK.

2	Cancel.

3	Help.

4	Yes.

5	No.

Each setting has three associated pictures: up, down and disabled. Any picture specified by Picture, PictureDown or PictureDisabled takes precedence over PredefPicture. The "down" pictures are only used if BevelWidth is two or less, otherwise the "up" picture is used!

Data Type	Integer (enumerated)


Placement
    Placement Property

Description	Determines the placement of the picture with respect to the caption text.

Remarks	The Placement property settings are:

Setting	Description

0	(Default) The picture appears horizontally centered at the top of the button and the caption text appears below.

1	The picture appears vertically centered at the right of the button and the caption text appears to the left.

2	The picture appears horizontally centered at the bottom of the button and the caption text appears above.

3	The picture appears vertically centered at the left of the button and the caption text to the right.

4	The picture appears both vertically and horizontally centered and the caption will be drawn on top of the picture if necessary.

Data Type	Integer (enumerated)


Font3D
    Font3D Property

Description	Sets or returns the three-dimensional style of the command button caption.

Remarks	The following table lists the Font3D property settings for the 3D command button control:

Setting	Description

0	(Delault) No shading. Caption is displayed flat (not three-dimensional).

1	Raised with light shading. Caption appears raised off the screen.

2	Raised with heavy shading. Caption appears more raised.

3	Inset with light shading. Caption appears inset on the screen.

4	Inset with heavy shading. Caption appears more inset.

Data Type	Integer (enumerated)


Picture
    Picture Property

Description	Specifies a bitmap or an icon to display on the command button.

Remarks	The Placement property determines where the picture will be placed with respect to the caption.

Data Type	Picture


AutoPictureDisabled
  AutoPictureDisabled Property

Description	Attempts to automatically give the picture (if any) a "disabled" look when the Enabled property is set to False.

Remarks	The AutoPictureDisabled property settings are:

Setting	Description

0	(Default) No attempt is made to give any picture a disabled look.

1	The picture's contour appears inset on the screen.

2	The picture's contour appears raised off the screen.

3	The picture itself appears inset on the screen.

4	The picture itself appears raised the screen.

5	All contours appears inset on the screen. Some contours will be two pixels thick.

6	All contours appears raised off the screen. Some contours will be two pixels thick.

7	All contours appears inset on the screen. Some contours will disappear.

8	All contours appears raised off the screen. Some contours will disappear.

The first four styles (operating on the whole picture) requires the TransColor property to be set to the picture's background color, even if the transparent feature isn't used (this isn't necessary for icons, however).

Data Type	Integer (enumerated)


DropShadow
  DropShadow Property

Description	Creates a drop shadow effect on the picture when the button is depressed.

Remarks	When this feature is in effect, the picture will appear to hang above the button surface when the button is depressed, casting a shadow on the button surface. If the picture is a bitmap, then the TransColor property must also be used.

Data Type	Integer (Boolean)